#pragma once

namespace gtl
{
	namespace patterns
	{
		template<class Component, class Decorator>
		class decorator : public Component
		{
		public:
			typedef Component component_type;
			typedef Decorator decorator_type;

		public:
			decorator() { _decoratorptr = NULL; }
			virtual ~decorator() {
				if(NULL != _decoratorptr)
					delete _decoratorptr;
			}

		public:
			decorator_type* get_decorator(void) { return _decoratorptr; }
			void attach(decorator_type* decoratorptr) {
				decorator_type* ptr = _decoratorptr;
				_decoratorptr = decoratorptr; 
				if(NULL != ptr)
					delete ptr;
			}

		protected:
			decorator_type* _decoratorptr;
		};
	}
}